import json

from config import BASE_DIR


# def add(*args):
#     sums = 0
#     for arg in args:
#         sums = sums + arg
#         print(arg, " ", end="")
#     print(sums)

def add(a, b):
 return a + b

# 读取json数据-元素为列表
def build_add_json_data():
    with open('../data/json_data.json') as f:
        json_data = json.load(f)
    return json_data

# 读取json数据-元素为字典
def build_add_json_data2():
    with open('../data/json_data2.json') as f:
        json_data_list = json.load(f) # [{}, {}, {}] ----> [(), ()]
        new_list = []
        for json_data in json_data_list:
            a = json_data.get('a')
            b = json_data.get('b')
            expected = json_data.get('expected')
            new_list.append((a, b, expected))
        return new_list

def build_login_data():
    with open(BASE_DIR + '/data/login_json_data.json', encoding='utf-8') as f:
        data_list = json.load(f) # [{}, {}] ---> [()]
        new_list = []
        for data in data_list:
        # 字典中的 desc 不需要
            username = data.get('username')
            password = data.get('password')
            expect = data.get('expect')
            new_list.append((username, password, expect))
        return new_list

if __name__ == '__main__':
    add(1, 2)